﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skynet.BusinessEntities;
using Skynet.BusinessLogic.DataAccess;
using Microsoft.Practices.Unity;

namespace Skynet.DataAccess
{
    public class OrganizationRepository  :MasterRepository<Organization>, IOrganizationRepository
    {
        public OrganizationRepository(IUnityContainer container)
            : base(container)
        {

        }
        public override void Maintenance(Organization item)
        {
            var ctx = this.ContainerService.Resolve<SkyNetLibraryEntities>();
            ctx.Organizations.ApplyChanges(item);
            ctx.SaveChanges(); 
        }
        public override Organization GetOne(object key)
        {
            var ctx = this.ContainerService.Resolve<SkyNetLibraryEntities>();
            var query =( from c in ctx.Organizations where c.Id == (Guid)key select c).FirstOrDefault();
            return query; 
        }
        
    }
}
